/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.quotes.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedNativeQueries;
import javax.persistence.NamedNativeQuery;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author rmatos
 */
@Entity
@Table(name = "tbl_quote")
@NamedNativeQueries({

    @NamedNativeQuery(name="TblQuote.getRandomQuote", query="SELECT t.name,t.quote,t.picture_url from tbl_quote t", resultClass=TblQuote.class)

})
@NamedQueries({

    @NamedQuery(name = "TblQuote.findAll", query = "SELECT t FROM TblQuote t"),
    @NamedQuery(name = "TblQuote.findById", query = "SELECT t FROM TblQuote t WHERE t.id = :id"),
    @NamedQuery(name = "TblQuote.findByName", query = "SELECT t FROM TblQuote t WHERE t.name = :name"),
    @NamedQuery(name = "TblQuote.findByQuote", query = "SELECT t FROM TblQuote t WHERE t.quote = :quote"),
    @NamedQuery(name = "TblQuote.findByPictureUrl", query = "SELECT t FROM TblQuote t WHERE t.pictureUrl = :pictureUrl"),
    @NamedQuery(name=  "TblQuote.findAllName", query="SELECT distinct t.name from TblQuote t ORDER BY t.name"),
    @NamedQuery(name=  "TblQuote.findAllQuoteByName" , query="SELECt t.quote from TblQuote t WHERE t.name = :name")

})
public class TblQuote implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Integer id;
    @Column(name = "name")
    private String name;
    @Basic(optional = false)
    @Column(name = "quote")
    private String quote;
    @Column(name = "picture_url")
    private String pictureUrl;

    public TblQuote() {
    }

    public TblQuote(Integer id) {
        this.id = id;
    }

    public TblQuote(Integer id, String quote) {
        this.id = id;
        this.quote = quote;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getQuote() {
        return quote;
    }

    public void setQuote(String quote) {
        this.quote = quote;
    }

    public String getPictureUrl() {
        return pictureUrl;
    }

    public void setPictureUrl(String pictureUrl) {
        this.pictureUrl = pictureUrl;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof TblQuote)) {
            return false;
        }
        TblQuote other = (TblQuote) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.quotes.entities.TblQuote[id=" + id + "]";
    }

}
